<template>
  <el-drawer v-model="addDrawer" size="48%" :show-close="false" @opened="openDrawer" @close="closeDrawer">
    <template #title>
      <h2><svg-icon icon-class="list"></svg-icon><span style="padding-left: 15px">{{ typeName }}</span></h2>
      <el-button type="primary" @click="confirmClick" :disabled="drawerLoading" v-if="isShowSave">保存</el-button>
    </template>
    <template #default>
      <el-form :model="form" ref="addRef" :inline="true" :rules="formRules" label-width="160px" v-loading="drawerLoading">
        <el-row justify="space-between">
          <el-form-item label="省">
            <el-input v-model="form.province" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="市">
            <el-input v-model="form.city" clearable disabled></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="区/县">
            <el-input v-model="form.county" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="地层点编号" prop="id">
            <el-input v-model="form.id" placeholder="请输入地层点编号" clearable maxlength="17"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="地质调查观测点编号" prop="geologicalSvyPointId">
            <el-input v-model="form.geologicalSvyPointId" placeholder="请输入地质调查观测点编号" clearable maxlength="17"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="野外编号" prop="fieldId" style="width: 100%">
            <el-input v-model="form.fieldId" placeholder="请输入野外编号" :autosize="{ minRows: 2, maxRows: 4 }" type="textarea"
              show-word-limit maxlength="50" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="地层名称" prop="stratigraphyName" style="width: 100%">
            <el-input v-model="form.stratigraphyName" placeholder="请输入地层名称" :autosize="{ minRows: 2, maxRows: 4 }"
              type="textarea" show-word-limit maxlength="50" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="走向 [°]" prop="strike">
            <el-input v-model.number="form.strike" placeholder="请输入走向 [°]" clearable maxlength="4"></el-input>
          </el-form-item>
          <el-form-item label="实测倾向 [度]" prop="dip">
            <el-input v-model.number="form.dip" placeholder="请输入实测倾向 [度]" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="倾角 [度]" prop="clination">
            <el-input v-model.number="form.clination" placeholder="请输入倾角 [度]" clearable maxlength="4"></el-input>
          </el-form-item>
          <el-form-item label="接触关系" prop="touchRelation">
            <dict-select code="StraTouchTypeCVD" :value="form.touchRelation"
              @update="updateDict('touchRelation', $event)"></dict-select>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="接触关系描述" prop="touchReDescription" style="width:100%">
            <el-input v-model="form.touchReDescription" placeholder="请输入接触关系描述" :autosize="{ minRows: 4, maxRows: 8 }"
              type="textarea" show-word-limit maxlength="255" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="地层厚度 [米]" prop="thickness" style="width:100%">
            <el-input v-model="form.thickness" placeholder="请输入地层厚度 [米]" :autosize="{ minRows: 2, maxRows: 4 }"
              type="textarea" show-word-limit maxlength="50" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="地层描述" prop="stratigraphyDescription" style="width:100%">
            <el-input v-model="form.stratigraphyDescription" placeholder="请输入地层描述" :autosize="{ minRows: 4, maxRows: 8 }"
              type="textarea" show-word-limit maxlength="255" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="数据来源" prop="dataSource">
            <el-input v-model.number="form.dataSource" placeholder="请输入数据来源" clearable maxlength="20"></el-input>
          </el-form-item>
          <el-form-item label="是否倒转地层产状" prop="isReversed">
            <dict-select code="TrueOrFalse" :value="form.isReversed"
              @update="updateDict('isReversed', $event)"></dict-select>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="典型照片文件编号" prop="photoAiid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.photoAiid" placeholder="请输入典型照片文件编号" clearable maxlength="20"></el-input>
              <ImageUpload v-model="form.photoAiidName" @uploadImage="uploadSuccess('photoAiid', $event)"
                @delFile="deleteFile('photoAiid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="典型照片原始文件编号" prop="photoArwid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.photoArwid" placeholder="请输入典型照片原始文件编号" clearable maxlength="20"></el-input>
              <FileUpload v-model="form.photoArwidName" @uploadFile="uploadSuccess('photoArwid', $event)"
                @delFile="deleteFile('photoArwid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="照片镜向" prop="photoViewingTo">
            <dict-select code="CVD-16-Direction" :value="form.photoViewingTo"
              @update="updateDict('photoViewingTo', $event)"></dict-select>
          </el-form-item>
          <el-form-item label="拍摄者" prop="photographer">
            <el-input v-model="form.photographer" placeholder="请输入拍摄者" clearable maxlength="20"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="典型剖面图图像文件编号" prop="typicalProfileAiid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.typicalProfileAiid" placeholder="请输入典型剖面图图像文件编号" clearable
                maxlength="20"></el-input>
              <ImageUpload v-model="form.typicalProfileAiidName"
                @uploadImage="uploadSuccess('typicalProfileAiid', $event)"
                @delFile="deleteFile('typicalProfileAiid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="典型剖面图原始文件编号" prop="typicalProfileArwid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.typicalProfileArwid" placeholder="请输入典型剖面图原始文件编号" clearable
                maxlength="20"></el-input>
              <FileUpload v-model="form.typicalProfileArwidName"
                @uploadFile="uploadSuccess('typicalProfileArwid', $event)"
                @delFile="deleteFile('typicalProfileArwid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="平面图文件编号" prop="sketchAiid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.sketchAiid" placeholder="请输入平面图文件编号" clearable maxlength="20"></el-input>
              <ImageUpload v-model="form.sketchAiidName" @uploadImage="uploadSuccess('sketchAiid', $event)"
                @delFile="deleteFile('sketchAiid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="平面图原始文件编号" prop="sketchArwid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.sketchArwid" placeholder="请输入平面图原始文件编号" clearable maxlength="20"></el-input>
              <FileUpload v-model="form.sketchArwidName" @uploadFile="uploadSuccess('sketchArwid', $event)"
                @delFile="deleteFile('sketchArwid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="是否修改工作底图" prop="ismodifyworkmap">
            <dict-select code="TrueOrFalse" :value="form.ismodifyworkmap"
              @update="updateDict('ismodifyworkmap', $event)"></dict-select>
          </el-form-item>
          <el-form-item label="是否在图中显示" prop="isInmap">
            <dict-select code="TrueOrFalse" :value="form.isInmap"
              @update="updateDict('isInmap', $event)"></dict-select>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="符号或标注旋转角度" prop="lastAngle">
            <el-input v-model.number="form.lastAngle" placeholder="请输入符号或标注旋转角度" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="备注" prop="commentInfo" style="width:100%">
            <el-input v-model="form.commentInfo" placeholder="请输入备注" :autosize="{ minRows: 6, maxRows: 12 }"
              type="textarea" show-word-limit maxlength="2147483647" clearable></el-input>
          </el-form-item>
        </el-row>
      </el-form>
    </template>
  </el-drawer>
</template>
<script setup>
import useSpatialData from '@/hooks/useSpatialData'
import { rangeValidate, eightDouble } from '@/utils/validate'
const { route, addDrawer, drawerLoading, form, typeName, openDrawer, closeDrawer, confirmClick, uploadSuccess, deleteFile, updateDict, isShowSave } = useSpatialData()
const formRules = {
  id: [{ required: true, message: '请填写地层点编号！', trigger: 'blur' }],
  strike: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 359, validator: rangeValidate }],
  dip: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 359, validator: rangeValidate }],
  clination: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 90, validator: rangeValidate }],
  lastAngle: [eightDouble]
}
</script>
<style scoped></style>